﻿//using Newtonsoft.Json;
using TouchSocket.Core;
using TouchSocket.Rpc.TouchRpc;
using TouchSocket.Sockets;
using Vampirewal.Admin.Test;

//using Vampirewal.Admin.Server.Model.Models.Systems.User;
//using Vampirewal.Admin.Server.Model.Systems.Dic;

//Console.WriteLine("Hello, World!");

test t1 = new test();
t1.aaaa();

Console.ReadLine();

public class test
{
    private HttpTouchRpcClient client { get; set; }

    public void aaaa()
    {
        client = new HttpTouchRpcClient();

        client.Setup(new TouchSocketConfig()
              .SetRemoteIPHost("127.0.0.1:7790")
              //.SetRemoteIPHost("tcp://sv1.k9s.run:46710")
              //.SetRemoteIPHost("124.223.66.212:7791")
              //.SetRemoteIPHost("tcp://cn-cd-txy-1.starryfrp.com:60073")
              //.SetRemoteIPHost(new IPHost("http://vampirerpc.sv1.k9s.run:2271"))
              .SetVerifyToken("VampirewalAdmin")
              .SetVerifyTimeout(600000)
              .SetRootPath(AppDomain.CurrentDomain.BaseDirectory)
              .ConfigurePlugins(c =>
              {
                  c.Add<TouchRpcActionPlugin<HttpTouchRpcClient>>()
                   .SetFileTransfered((client, e) =>
                   {
                       if (e.Result.ResultCode == ResultCode.Success)
                       {
                           var aaa = e.FileInfo;
                       }
                   });
              }));

        Sys_User user = new Sys_User()
        {
            UserId = "yunzhong1",
            Name = "yunzhong1",
            State = 1,
            OrgId = "30152ffe-d6ea-4fd5-89df-bf8eab0921ca",
            OrgName = "云众",
            TenantId = "c0598cee-6ba8-49e4-a8c7-d609b6ca1b9f",
            BillId = "43bd6f0f-c035-4e28-ba7c-f9bf163809c0",
        };
        //string str = JsonConvert.SerializeObject(user);

        client.Connect();

        //client.ResetID(str);

        //InvokeOption invokeOption = new InvokeOption();
        //invokeOption.SerializationType = TouchSocket.Core.Serialization.SerializationType.FastBinary;

        //var resultUser = client.Invoke<ResponseBasic>("vampirewal.admin.server.viewmodels.services.service.loginservice.login", InvokeOption.WaitInvoke, "yunzhong", "123");

        //for (int i = 0; i < 100; i++)
        //{
        //    Thread.Sleep(50);

        //    var resultUser = client.Invoke<PageContainer<Sys_DicCategory>>("vampirewal.admin.server.rpcservices.service.dicservice.getpagelistdiccategory", InvokeOption.WaitInvoke, new PageRequest());

        //    string str2 = JsonConvert.SerializeObject(resultUser);

        //    Console.WriteLine(str2);
        //}

        //client.Invoke("vampirewal.admin.server.rpcservices.service.clientnotifyservicee.sendmessage", InvokeOption.WaitInvoke, str, "傻屌");

        Console.WriteLine("调用完成!");

        Console.ReadKey();
    }
}

public class PageRequest
{
    private int _Page = 1;

    /// <summary>
    /// 当前页
    /// </summary>
    public int Page
    { get => _Page; set { _Page = value; } }

    private int _Limit = 20;

    /// <summary>
    /// 每页数
    /// </summary>
    public int Limit
    { get => _Limit; set { _Limit = value; } }

    private string _KeyWord;

    /// <summary>
    /// 关键词
    /// </summary>
    public string KeyWord
    {
        get { return _KeyWord; }
        set { _KeyWord = value; }
    }
}